﻿using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Silverlight3dApp.Learning.Lesson07
{
    public class ModelManager : DrawableGameComponent
    {
        private readonly List<BasicModel> _models = new List<BasicModel>();

        public ModelManager(Game game) : base(game)
        {
        }

        public override void Initialize()
        {
            base.Initialize();
        }

        protected override void LoadContent()
        {
            _models.Add(new BasicModel(Game.Content.Load<Model>(@"Models/spaceship")));
            //_models.Add(new SpinningEnemy(Game.Content.Load<Model>(@"Models/spaceship")));
            //_models.Add(new RunningEnemy(Game.Content.Load<Model>(@"Models/spaceship")));
            base.LoadContent();
        }

        public override void Update(GameTime gameTime)
        {
            foreach (var model in _models)
            {
                model.Update();
            }
            base.Update(gameTime);
        }

        public override void Draw(GameTime gameTime)
        {
            foreach (var model in _models)
            {
                model.Draw(((MadnessGame) Game).Camera);
            }
            base.Draw(gameTime);
        }
    }
}